/*
 * lineChart.fx
 *
 * Created on 23-dic-2009, 16:05:28
 */

package ProgramSamples.Graphics;

import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.stage.Alert;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
import javafx.scene.chart.*;
import javafx.scene.chart.part.*;



def lineSeries1: LineChart.Series = LineChart.Series {
    name: "Series 1"
    data: [
        LineChart.Data { xValue: 0 yValue: 34  action:function(){Alert.inform("Clicked on 0,34")} },
        LineChart.Data { xValue: 3 yValue: 27  action:function(){Alert.inform("Clicked on 3,27")} },
        LineChart.Data { xValue: 6 yValue: 42 fill: Color.RED action:function(){Alert.inform("Clicked on 6,42")} },
        LineChart.Data { xValue: 9 yValue: 50 },
        LineChart.Data {
            xValue: 12
            yValue: 64
            symbol: PlotSymbol.Circle { size: 15 fill: Color.RED }
        },
        LineChart.Data { xValue: 15 yValue: 56 },
        LineChart.Data { xValue: 18 yValue: 48 },
        LineChart.Data { xValue: 21 yValue: 34 },
        LineChart.Data { xValue: 24 yValue: 30}
    ]
    symbolCreator: function(series:LineChart.Series, seriesIndex:Integer, item:LineChart.Data,itemIndex:Integer, fill:Paint){
        PlotSymbol.HollowTriangle { fill: fill }
    }
};

def lineSeries2: LineChart.Series = LineChart.Series {
    name: "Series 2"
    data: [
        LineChart.Data { xValue: 0 yValue: 24 action:function(){Alert.inform("Clicked on 0,24")} },
        LineChart.Data { xValue: 3 yValue: 17 action:function(){Alert.inform("Clicked on 3,17")} },
        LineChart.Data { xValue: 6 yValue: -31 action:function(){Alert.inform("Clicked on 6,-31")} },
        LineChart.Data { xValue: 9 yValue: -28 },
        LineChart.Data { xValue: 12 yValue: -10 },
        LineChart.Data { xValue: 15 yValue: -18 },
        LineChart.Data { xValue: 18 yValue: 25 },
        LineChart.Data { xValue: 21 yValue: 28 },
        LineChart.Data { xValue: 24 yValue: 10 }
    ]
    symbolCreator: function(series:LineChart.Series, seriesIndex:Integer, item:LineChart.Data,itemIndex:Integer, fill:Paint){
        PlotSymbol.Cross {
            fill: fill
        }
    }
};

def lineSeries3: LineChart.Series = LineChart.Series {
    name: "Series 3"
    data: [
        LineChart.Data { xValue: 0 yValue: 18 action:function(){Alert.inform("Clicked on 0,18")} },
        LineChart.Data { xValue: 3 yValue: 25 action:function(){Alert.inform("Clicked on 3,25")} },
        LineChart.Data { xValue: 6 yValue: 14 action:function(){Alert.inform("Clicked on 6,14")} },
        LineChart.Data { xValue: 9 yValue: 18 },
        LineChart.Data { xValue: 12 yValue: 22 },
        LineChart.Data { xValue: 15 yValue: 16 },
        LineChart.Data { xValue: 18 yValue: 14 },
        LineChart.Data { xValue: 21 yValue: 12 },
        LineChart.Data { xValue: 24 yValue: 8 }
    ]
}


def lineChart =  LineChart {
    title: "Temperature Monitoring (in degree C)"
    data: [lineSeries1, lineSeries2, lineSeries3]
    xAxis: NumberAxis {
        side: Side.TOP
        label: "Time"
        lowerBound: 0
        upperBound: 24
        tickUnit: 2
        formatTickLabel: function(value):String { "{(value as Float) as Integer}" }
    }
    yAxis: NumberAxis {
        side: Side.RIGHT
        label: "Temperature"
        lowerBound: -40
        upperBound: 100
        tickUnit: 20
    }
}


Stage {
    title: "Line Chart"
    scene: Scene{
	    width: 540
            height: 410
            content: lineChart
     } //Scene
}//Stage